package cn.fancy.sdk.common.utils;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class Aes
{
	public static String ENCRYPT = "en";
	public static String DECRYPT = "de";

    private static Cipher encrypt;
    
    private static Cipher decrypt;
    
    private static String key = "088c80bf980469c3";
    
    static 
    {
        	  try
        	  {
                byte[] raw = key.getBytes("ASCII");
                SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
               
                Cipher en_cipher = Cipher.getInstance("AES");
                en_cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
                
                encrypt = en_cipher;
                
                Cipher de_cipher = Cipher.getInstance("AES");
                de_cipher.init(Cipher.DECRYPT_MODE, skeySpec);
                
                decrypt = de_cipher;
        	  }
        	  catch(Exception e)
        	  {
        		  e.printStackTrace();
        	  }
      }
            
          

    public static byte[] Decrypt(byte[] sSrc) 
    {
        
        try
        {
            byte[] original = decrypt.doFinal(sSrc);
            return original;
        }
        catch (Exception ex)
        {
           
        }
        return null;
    }

    public static byte[] Encrypt(byte[] ssrc) 
    {

        
        try
        {
            byte[] encrypted = encrypt.doFinal(ssrc);
            return encrypted;
        }
        catch (Exception e)
        {
        
        }
        
        return null;
       
    }
    
    
    

}
